unit PesquisaConfiguracaoBoleto;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFormPesquisa, DB, DBTables, StdCtrls, Grids, DBGrids, Buttons,
  ExtCtrls, DBCtrls;

type
  TFPesquisaConfiguracaoBoleto = class(TFormPesquisa)
    Label1: TLabel;
    ECodigo: TEdit;
    EDescricao: TEdit;
    Label2: TLabel;
    procedure BtnSelecionarClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure DBLCBContaKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure BtnConsultarClick(Sender: TObject);
    procedure BtnLimparClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FPesquisaConfiguracaoBoleto: TFPesquisaConfiguracaoBoleto;

implementation

uses ConfiguracaoBoleto;

{$R *.dfm}

procedure TFPesquisaConfiguracaoBoleto.BtnSelecionarClick(Sender: TObject);
begin
  inherited;
 FCadastroConfBoleto.QConfBoleto.Close;
 FCadastroConfBoleto.QConfBoleto.Open;
 FCadastroConfBoleto.QConfBoleto.Locate('CONFBOL_CODIGO',QPesquisa.fieldByname('CONFBOL_CODIGO').AsString,[loCaseInsensitive]);
 Self.Close;

end;

procedure TFPesquisaConfiguracaoBoleto.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 FCadastroConfBoleto.Enabled:=true;
 FCadastroConfBoleto.Show;
 FPesquisaConfiguracaoBoleto:=nil;
 inherited;
end;

procedure TFPesquisaConfiguracaoBoleto.DBLCBContaKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  case key of
  116 : begin //F5
          TDBLookupComboBox(Sender).ListSource.DataSet.Close;
          TDBLookupComboBox(Sender).ListSource.DataSet.Open;
        end ;
 end;

end;

procedure TFPesquisaConfiguracaoBoleto.BtnConsultarClick(Sender: TObject);
begin
 QPesquisa.Close;
 QPesquisa.SQL.Clear;
 QPesquisa.SQL.Add('Select * from CONFIGURACAO_BOLETO ');
 QPesquisa.SQL.Add('Where (CONFBOL_CODIGO = CONFBOL_CODIGO) ');
 if ECodigo.Text <> '' then
  begin
   QPesquisa.SQL.Add(' And (CONFBOL_CODIGO = :Cod) ');
   QPesquisa.ParamByName('Cod').AsString:=ECodigo.Text;
  end;

 if EDescricao.Text <> '' then
  begin
   QPesquisa.SQL.Add(' And (CONFBOL_DESCRICAO LIKE :DESC) ');
   QPesquisa.ParamByName('DESC').AsString:=EDescricao.Text + '%';
  end;
 QPesquisa.SQL.Add(' Order By CONFBOL_CODIGO ');
 QPesquisa.Open;
 inherited;
 BtnImprimir.Enabled:=false;
end;

procedure TFPesquisaConfiguracaoBoleto.BtnLimparClick(Sender: TObject);
begin
  inherited;
 ECodigo.Text:='';
 EDescricao.Text:='';
end;

end.
